﻿#region Using

using GameLogic.External;

#endregion

namespace GameLogic.Internal
{

    #region Using

    #endregion

    internal class Castle : Building
    {
        public Castle(Tile tile)
            : base(tile, BuildingType.Castle)
        {
            this.ProgressTimer.Elapsed += this.OnProgressTimerElapsed;
        }

        internal override void Update(GameTime gameTime)
        {
            this.FarmerQueue.Clear();

            if (this.ProgressTimer.Enabled)
            {
                this.ProgressTimer.Update(gameTime);
            }
            else
            {
                this.ProgressTimer.Start(this.Settings.CastleProduktionTime);
            }
        }

        internal override void Reset()
        {
            this.ProgressTimer.Stop();
            this.ProgressTimer.Reset();
        }

        private void OnProgressTimerElapsed(ProgressTimer source)
        {
            new Farmer(this.Tile.Owner).ArriveAt(this.Tile);
            new Militia(this.Tile.Owner).ArriveAt(this.Tile);
        }
    }
}